package org.jmh.gift.strategy;

import cn.hutool.core.util.StrUtil;

public class ShopCarStrategyFactory {


    public static IShopCarStrategy createStrategy(String className){
        if(StrUtil.isBlank(className)){
            throw new RuntimeException("strategy name is not black");
        }
        try {
            Class<?> aClass = Class.forName(className);
            Object obj = aClass.newInstance();
            if(obj instanceof IShopCarStrategy){
                return (IShopCarStrategy)obj;
            }
            throw new RuntimeException("this strategy is not support");
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e.getMessage());
        }
    }

}
